<template>
	<view class="cSD" :class="[datMsg.applyStatus == 1? 'csDD' : '']">
		<view class="">
			<view class="cSDhead" v-if="datMsg.applyStatus == 1">
				<view class="cSDheadBox">
					<view class="cSDheadBoxTop">
						<image class="cSDheadBoxTopImg" src="https://www.zzzsyh.com/applets/agent/agent/shenhe.png"
							mode=""></image>
						<text>市县鉴定结果：</text>
					</view>
					<view class="cSDheadBoxCen">
						{{datMsg.auditContent}}
					</view>
					<view class="cSDheadBoxBtm">
						鉴定时间：{{datMsg.auditTime}}
					</view>
				</view>
			</view>
			<view class="cSDheadT" v-if="datMsg.applyStatus == 2 || datMsg.applyStatus == 4">
				<view class="cSDheadTBox">
					<view class="cSDheadTTop">
						<image class="cSDheadTTopImg" src="https://www.zzzsyh.com/applets/agent/agent/bohui_small.png"
							mode=""></image>
						<text>驳回：</text>
					</view>
					<view class="" v-if="datMsg.applyStatus == 2">
						<view class="cSDheadTCen">
							{{datMsg.auditContent}}
						</view>
						<view class="cSDheadBoxBtm">
							鉴定时间：{{datMsg.auditTime}}
						</view>
					</view>
					
					<view class="" v-if="datMsg.applyStatus == 4">
						<view class="cSDheadTCen">
							{{datMsg.agentContent}}
						</view>
						<view class="cSDheadBoxBtm">
							鉴定时间：{{datMsg.agentTime}}
						</view>
					</view>
					
				</view>
			</view>
			<view class="cSDheadT cSDheadTS" v-if="datMsg.applyStatus == 3 || datMsg.applyStatus == 5 || datMsg.applyStatus == 6 || datMsg.applyStatus == 7">
				<view class="cSDheadTBox02">
					<view class="cSDheadTTop cSDheadTTopS">
						<image class="cSDheadTTopImg" src="https://www.zzzsyh.com/applets/agent/agent/pass_small.png"
							mode=""></image>
						<text>通过：</text>
					</view>
					<view class="cSDheadBoxBtm">
						鉴定时间：
						<text v-if="datMsg.applyStatus == 3">{{datMsg.agentTime}}</text>
						<text v-else>{{datMsg.platformTime}}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="cSDMain" :class="[datMsg.applyStatus == 1? 'cSDMainD' : '']">
			<view class="cSDMainBox">
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						申请时间
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.createTime}}
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						申请人电话
					</view>
					<view class="cSDMainBoxLiR">
						{{changePhone(datMsg.storePhone)}}
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						故障配件名称
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.partsName}}
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						补助金额
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.payPrice}}元
					</view>
				</view>
				<view class="cSDMainBoxLi btb">
					<view class="cSDMainBoxLiL">
						鉴定市县
					</view>
					<view class="cSDMainBoxLiR">
						<text>{{datMsg.partsStorePerson}}</text>
						<text style="margin-left: 20rpx;">{{datMsg.partsStorePhone}}</text>
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						产品规格
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.attributeName}}
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						安装日期
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.installTime}}
					</view>
				</view>
				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						安装凭证
					</view>
					<view class="cSDMainBoxLiR">
						<image v-for="(ite,ind) in changeImgs(datMsg.installImages)"
							@click="previewImage(changeImgs(datMsg.installImages), ind)" :key="ind"
							class="cSDMainBoxLiRImg" :src=ite mode=""></image>
					</view>
				</view>

				<view class="cSDMainBoxLi bt">
					<view class="cSDMainBoxLiL">
						申请补助金信息
					</view>
					<view class="cSDMainBoxLiR">
						<image v-for="(ite,ind) in changeImgs(datMsg.faultImages)" :key="ind"
							@click="previewImage(changeImgs(datMsg.faultImages), ind)" class="cSDMainBoxLiRImg" :src=ite
							mode=""></image>
					</view>
				</view>
				<view class="cSDMainBoxLi btbt" v-if="datMsg.applyStatus != 1">
					<view class="cSDMainBoxLiL">
						市县鉴定结果
					</view>
					<view class="cSDMainBoxLiR">
						{{datMsg.auditContent}}
					</view>
				</view>
			</view>
		</view>
		<view class="cSDMessage" v-if="datMsg.applyStatus == 4">
			<view class="cSDMessageHead">
				驳回原因：
			</view>
			<view class="cSDMessageContent" v-if="datMsg.agentContent">
				{{datMsg.agentContent}}
			</view>
			<view class="cSDMessageContent" v-else>
				无
			</view>
		</view>
		<view class="cSDBtn" v-if="datMsg.applyStatus == 1">
			<view class="cSDBtnL" @click="cli_bohui">
				驳回
			</view>
			<view class="cSDBtnR" @click="cli_tongguo">
				通过
			</view>
		</view>
		<uni-popup ref="popup" type="dialog">
			<view class="" v-if="show_dialog">
				<uni-popup-dialog mode="input" title="请输入驳回原因" :duration="2000" :before-close="true" @close="close"
					@confirm="confirm"></uni-popup-dialog>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				id: '',
				agentId: uni.getStorageSync('agentId'),
				datMsg: {
					partsName: '',
					payPrice: '',
					partsStorePerson: '',
					partsStorePhone: '',
					attributeName: '',
					installTime: '',
					auditContent: '',
					
				},
				show_dialog: false
			}
		},
		onLoad(val) {
			if (val) {
				this.id = val.id
			}
		},
		mounted() {
			this.getQrCodeApplyDetails()
		},
		methods: {
			// 图片预览
			previewImage(item, index) {
				console.log(item);
				// let lis = item.split()
				wx.previewImage({
					current: index, // 当前显示图片的http链接
					urls: item // 需要预览的图片http链接列表
				})
			},
			// 点击通过
			cli_tongguo() {
				this.saveQrCodeAppraisalByAgentId(3, '')
			},
			// 点击驳回
			cli_bohui() {
				this.$refs.popup.open()
				this.show_dialog = true
			},
			close() {
				this.$refs.popup.close()
				this.show_dialog = false
			},
			confirm(value) {
				if (value) {
					this.saveQrCodeAppraisalByAgentId(4, value)
					this.$refs.popup.close()
					this.show_dialog = false
				} else {
					uni.showToast({
						title: '请输入驳回原因',
						icon: 'none'
					})
				}
			},
			// 会长鉴定
			saveQrCodeAppraisalByAgentId(applyStatus, agentContent) {
				uni.request({
					url: allapi.saveQrCodeAppraisalByAgentId,
					data: {
						applyId: this.id,
						agentId: this.agentId,
						applyStatus: applyStatus,
						agentContent: agentContent
					},
					success: (res) => {
						console.log(res, '会长鉴定结果');
						uni.showToast({
							title: res.data.msg
						})

						setTimeout(() => {
							uni.navigateBack()
						}, 500)
					}
				})
			},
			// 获取详情
			getQrCodeApplyDetails() {
				uni.request({
					url: allapi.getQrCodeApplyDetails,
					data: {
						applyId: this.id
					},
					success: (res) => {
						console.log('获取详情', res);
						let dat = res.data.data
						this.datMsg = dat
					}
				})
			},
			changeImgs(val) {
				if (val) {
					return val.split('|')
				} else {
					return []
				}
			},
			changePhone (val) {
				if (val) {
					let num = val.slice(0, 4) + '****' + val.slice(8,11)
					return num
				}else {
					return '暂无联系电话'
				}
			},
		}
	}
</script>

<style scoped>
	.bt {
		border-bottom: 1rpx solid #EEEEEE;
	}

	.btb {
		border-bottom: 16rpx solid #F3F5F6;
	}

	.btbt {
		border-top: 16rpx solid #F3F5F6;
	}

	.cSD {
		position: absolute;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		overflow: auto;
	}

	.csDD {
		background: #28CD50;
	}

	.cSDhead {
		min-height: 266rpx;
	}

	.cSDheadBox {
		margin: 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		min-height: 154rpx;
		padding: 24rpx 32rpx;
	}

	.cSDheadBoxTop {
		color: #333333;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 44rpx;
		display: flex;
		align-items: center;
	}

	.cSDheadBoxTopImg {
		width: 48rpx;
		height: 48rpx;
		margin-right: 16rpx;
		/* background: red; */
	}

	.cSDheadBoxCen {
		color: #000000;
		font-weight: 500;
		font-size: 36rpx;
		line-height: 50rpx;
		margin-top: 18rpx;
	}

	.cSDheadBoxBtm {
		margin-top: 16rpx;
		font-weight: 400;
		color: #8C8C8C;
		line-height: 40rpx;
		font-size: 28rpx;
	}

	.cSDheadT {
		background: #FEEFEF;
		
		position: relative;
	}

	.cSDheadTS {
		background: #E3FFE9;
	}
	.cSDheadTBox {
		background: url('https://www.zzzsyh.com/applets/agent/agent/bohui_big.png');
		background-repeat: no-repeat;
		background-size: 100%;
		padding: 32rpx;
	}
	.cSDheadTBox02 {
		background: url('https://www.zzzsyh.com/applets/agent/agent/pass_big.png');
		background-repeat: no-repeat;
		background-size: 100%;
		padding: 32rpx;
	}
	.cSDheadTTop {
		display: flex;
		align-items: center;
		color: #E9635D;
		line-height: 66rpx;
		font-size: 48rpx;

	}

	.cSDheadTTopS {
		color: #28CD50;
		margin-bottom: 32rpx;
	}

	.cSDheadTTopImg {
		width: 64rpx;
		height: 64rpx;
		/* background: red; */
		margin-right: 16rpx;
	}

	.cSDheadTCen {
		font-size: 28rpx;
		font-weight: 400;
		color: #000000;
		line-height: 56rpx;
		margin: 32rpx 0;
	}

	.cSDMain {
		flex: 1;
		overflow: auto;
		background: #FFFFFF;
	}

	.cSDMainD {
		border-top-left-radius: 24rpx;
		border-top-right-radius: 24rpx;
	}

	.cSDMainBox {
		border-radius: 16rpx;
	}

	.cSDMainBoxLi {
		display: flex;
		padding: 26rpx 32rpx;
		justify-content: space-between;
		/* margin-bottom: 44rpx; */
	}

	.cSDMainBoxLiL {
		width: 228rpx;
		font-size: 32rpx;
		/* font-weight: 400; */
		color: #777777;
		line-height: 44rpx;
	}

	.cSDMainBoxLiR {
		flex: 1;
		margin-left: 8rpx;
		font-size: 32rpx;
		color: #333333;
		line-height: 44rpx;
		text-align: right;
		font-weight: bold;
	}

	.cSDMainBoxLiRImg {
		width: 120rpx;
		height: 120rpx;
		background: #EEEEEE;
		border-radius: 8rpx;
		margin-right: 16rpx;
	}

	.cSDMessage {
		margin: 24rpx;
		padding: 48rpx 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
	}

	.cSDMessageHead {
		font-size: 28rpx;
		color: #666666;
		font-weight: 400;
	}

	.cSDMessageContent {
		margin-top: 24rpx;
		font-size: 28rpx;
		color: #333333;
		line-height: 56rpx;
	}

	.cSDBtn {
		height: 120rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 32rpx;
		padding-bottom: 68rpx;
		box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.12);
	}

	.cSDBtnL {
		width: 296rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: #F3F5F6;
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #333333;
	}

	.cSDBtnR {
		width: 296rpx;
		height: 88rpx;
		line-height: 88rpx;
		background: linear-gradient(90deg, #2ACE52 0%, #1DC248 100%);
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
	}
</style>
